<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::get('login', 'LoginController@showLoginForm')->name('admin.login');
Route::post('login', 'LoginController@login');
Route::get('logout', 'LoginController@logout');
Route::post('logout', 'LoginController@logout');

//Route::get('/', 'IndexController@index');


Route::get('index', ['as' => 'admin.index', 'uses' => function () {
    return redirect('/admin/setting/welcome');
}]);


Route::group(['middleware' => ['auth:admin', 'menu', 'authAdmin']], function () {

    //------------------------------------权限管理-------------------------------------------------------//

    Route::get('permission/{cid}/create', ['as' => 'admin.permission.create', 'uses' => 'PermissionController@create']);
    Route::get('permission/manage', ['as' => 'admin.permission.manage', 'uses' => 'PermissionController@index']);
    Route::get('permission/{cid?}', ['as' => 'admin.permission.index', 'uses' => 'PermissionController@index']);
    Route::post('permission/index', ['as' => 'admin.permission.index', 'uses' => 'PermissionController@index']); //查询
    Route::resource('permission', 'PermissionController', ['names' => ['update' => 'admin.permission.edit', 'store' => 'admin.permission.create']]);


    //------------------------------------角色管理---------------------------------------------------//

    Route::get('role/index', ['as' => 'admin.role.index', 'uses' => 'RoleController@index']);
    Route::post('role/index', ['as' => 'admin.role.index', 'uses' => 'RoleController@index']);
    Route::resource('role', 'RoleController', ['names' => ['update' => 'admin.role.edit', 'store' => 'admin.role.create']]);


    //------------------------------------用户管理-----------------------------------------------//

    Route::get('user/index', ['as' => 'admin.user.index', 'uses' => 'UserController@index']);  //用户管理
    Route::post('user/index', ['as' => 'admin.user.index', 'uses' => 'UserController@index']);
    Route::resource('user', 'UserController', ['names' => ['update' => 'admin.role.edit', 'store' => 'admin.role.create']]);

    //-------------------------------------广告--------------------------------------------------//
    // 产品模块
    Route::get('rank', ['as' => 'admin.rank', 'uses' => 'RankController@index']);
    // 产品列表(展示页)
    Route::get('rank/index', ['as' => 'admin.rank.index', 'uses' => 'RankController@index']);
    // 产品详情展示页
    Route::get('rank/show/{id}', ['as' => 'admin.rank.show', 'uses' => 'RankController@show']);
    // 新建产品审核
    Route::any('rank/create', ['as' => 'admin.rank.create', 'uses' => 'RankController@create']);
    // 修改产品详情审核
    Route::any('rank/edit/{id}', ['as' => 'admin.rank.edit', 'uses' => 'RankController@edit']);


    //-------------------------------------广告--------------------------------------------------//
    // 产品模块
    Route::get('query', ['as' => 'admin.query', 'uses' => 'QueryListController@index']);
    // 产品列表(展示页)
    Route::get('query/index', ['as' => 'admin.query.index', 'uses' => 'QueryListController@index']);
    // 产品详情展示页
    Route::get('query/show/{id}', ['as' => 'admin.query.show', 'uses' => 'QueryListController@show']);
    // 新建产品审核
    Route::any('query/create', ['as' => 'admin.query.create', 'uses' => 'QueryListController@create']);
    // 修改产品详情审核
    Route::any('query/edit/{id}', ['as' => 'admin.query.edit', 'uses' => 'QueryListController@edit']);


    //-------------------------------------广告--------------------------------------------------//
    // 产品模块
    Route::get('pay', ['as' => 'admin.pay', 'uses' => 'PayController@index']);
    // 产品列表(展示页)
    Route::get('pay/index', ['as' => 'admin.pay.index', 'uses' => 'PayController@index']);
    // 产品详情展示页
    Route::get('pay/show/{id}', ['as' => 'admin.pay.show', 'uses' => 'PayController@show']);
    // 新建产品审核
    Route::any('pay/create', ['as' => 'admin.pay.create', 'uses' => 'PayController@create']);
    // 修改产品详情审核
    Route::any('pay/edit/{id}', ['as' => 'admin.pay.edit', 'uses' => 'PayController@edit']);
    // 产品上线
    Route::get('pay/online/{id}', ['as' => 'admin.pay.online', 'uses' => 'PayController@online']);
    // 产品下线
    Route::get('pay/offline/{id}', ['as' => 'admin.pay.offline', 'uses' => 'PayController@offline']);




    //-------------------------------------广告--------------------------------------------------//
    // 产品模块
    Route::get('customer', ['as' => 'admin.customer', 'uses' => 'CustomerController@index']);
    // 产品列表(展示页)
    Route::get('customer/index', ['as' => 'admin.customer.index', 'uses' => 'CustomerController@index']);
    // 产品详情展示页
    Route::get('customer/show/{id}', ['as' => 'admin.customer.show', 'uses' => 'CustomerController@show']);
    // 新建产品审核
    Route::any('customer/create', ['as' => 'admin.customer.create', 'uses' => 'CustomerController@create']);
    // 修改产品详情审核
    Route::any('customer/edit/{id}', ['as' => 'admin.customer.edit', 'uses' => 'CustomerController@edit']);
    // 产品上线
    Route::get('customer/online/{id}', ['as' => 'admin.customer.online', 'uses' => 'CustomerController@online']);
    // 产品下线
    Route::get('customer/offline/{id}', ['as' => 'admin.customer.offline', 'uses' => 'CustomerController@offline']);



    // 产品模块
    Route::get('config', ['as' => 'admin.config', 'uses' => 'SconfigController@index']);
    // 产品列表(展示页)
    Route::get('config/index', ['as' => 'admin.config.index', 'uses' => 'SconfigController@index']);
    // 新建产品审核
    Route::any('config/create', ['as' => 'admin.config.create', 'uses' => 'SconfigController@create']);
    // 修改产品详情审核
    Route::any('config/edit/{id}', ['as' => 'admin.config.edit', 'uses' => 'SconfigController@edit']);



    //-------------------------------------订单--------------------------------------------------//
    // 订单
    Route::get('order', ['as' => 'admin.order', 'uses' => 'OrderController@index']);
    // 订单
    Route::get('order/index', ['as' => 'admin.order.index', 'uses' => 'OrderController@index']);
//    Route::post('order/create', ['as' => 'admin.order.create', 'uses' => 'OrderController@create']);
    Route::any('order/create/{id}', ['as' => 'admin.order.create', 'uses' => 'OrderController@create']);
    Route::any('order/edit/{id}', ['as' => 'admin.order.edit', 'uses' => 'OrderController@edit']);
    Route::post('order/lendRecords', ['as' => 'admin.order.lendRecords', 'uses' => 'OrderController@lendRecords']);
    Route::post('order/rejectRecords', ['as' => 'admin.order.rejectRecords', 'uses' => 'OrderController@rejectRecords']);



    // 订单
    Route::get('users', ['as' => 'admin.users', 'uses' => 'OrderController@index']);
    // 订单
    Route::get('users/index', ['as' => 'admin.users.index', 'uses' => 'OrderController@index']);

    // 申请卖家
    Route::get('apply', ['as' => 'admin.apply', 'uses' => 'ApplyController@index']);
    // 订单
    Route::get('apply/index', ['as' => 'admin.apply.index', 'uses' => 'ApplyController@index']);
    // 产品上线
    Route::get('apply/online/{id}', ['as' => 'admin.apply.online', 'uses' => 'ApplyController@online']);
    // 产品下线
    Route::get('apply/offline/{id}', ['as' => 'admin.apply.offline', 'uses' => 'ApplyController@offline']);

    // 申请卖家
    Route::get('users', ['as' => 'admin.users', 'uses' => 'UsersController@index']);
    // 订单
    Route::get('users/index', ['as' => 'admin.users.index', 'uses' => 'UsersController@index']);

    // 默认欢迎页面
    Route::any('setting/welcome', ['as' => 'admin.setting.welcome', 'uses' => 'SettingController@welcome']);



});

Route::get('/', function () {
    return redirect('/admin/index');
});

